package com.example.gank.adapter;

import android.content.Context;
import android.widget.ImageView;

import com.android.core.base.BaseRcvAdapter;
import com.android.core.base.BaseViewHolder;
import com.bumptech.glide.Glide;
import com.example.gank.R;
import com.example.gank.bean.WelfareGankBean;

import java.util.List;

/**
 * Created by bsx on 17-1-9.
 */

public class WelfareGankAdapter<T> extends BaseRcvAdapter<BaseViewHolder, T> {

    public WelfareGankAdapter(Context context, int layoutId, List<T> mList) {
        super(context, layoutId, mList);
    }

    @Override
    public void convert(BaseViewHolder holder, T t) {
        WelfareGankBean welfareGankBean = (WelfareGankBean) t;
        holder.setText(R.id.tv_title, welfareGankBean.getDesc());
        ImageView view = (ImageView) holder.getView(R.id.iv_cover);
        if (!welfareGankBean.getUrl().equals(view.getTag())) {
            Glide.with(context).load(welfareGankBean.getUrl())
                    .crossFade()
                    .placeholder(com.aidabaobei.core.R.mipmap.em_empty_photo)
                    .error(com.aidabaobei.core.R.mipmap.em_empty_photo)
                    .centerCrop()
                    .into((ImageView) holder.getView(R.id.iv_cover));
            view.setTag(R.id.image_tag, welfareGankBean.getUrl());
        }
    }


}
